﻿package com.moonshineproject.plugin.project.vo.flash 
{
	import flash.filesystem.File;
	
	public class BuildOptions 
	{
		public var customSDKPath:String;
		public function get customSDK():File
		{ 
			if (customSDKPath) 
			{
				var toRet:File = new File(customSDKPath);
				toRet.canonicalize();
				return toRet;
			}
			return null;
		}
		
		public var additional:String = "";
				
		public function parse(build:XMLList):void 
		{
			var options:XMLList = build.option;
			if (String(options.@customSDK).length > 0) 
			{
				customSDKPath = options.@customSDK;
			}
			additional = String(options.@additional);
		}
		
		public function toXML():XML
		{
			var build:XML = <build/>;
			//TODO: Implement & care about these hardcoded values.
			var pairs:Object = {
				accessible						:	"False",
				allowSourcePathOverlap 			:	"False",
				benchmark						:	"False",
				es								:	"False",
				loadConfig						:	"",
				optimize						:	"False",
				showActionScriptWarnings		:	"True",
				showBindingWarnings				:	"True",
				showDeprecationWarnings			:	"True",
				showUnusedTypeSelectorWarnings	:	"True",
				strict							:	"True",
				useNetwork						:	"True",
				useResourceBundleMetadata		:	"True",
				warnings						:	"True",
				verboseStackTraces				: 	"False",
				linkReport						:	"",
				loadExterns						:	"",
				additional						:	additional,
				customSDK						:	(customSDK) ? customSDK.nativePath : "" 
			};
			
			
			for (var i:String in pairs)
			{
				var option:XML = <option/>;
				option.@[i] = pairs[i];
				build.appendChild(option);
			}
			
			return build;
		}
		
	}
}